import { FormSchema, BasicColumn } from "/@/components/Table"
import { DescItem } from "/@/components/Description/index"
import { render } from "/@/utils/common/renderUtils"

export const columns: BasicColumn[] = [
  {
    title: "用户标识",
    dataIndex: "openId",
    width: 230,
  },
  {
    title: "昵称",
    dataIndex: "nickname",
    width: 120,
  },
  {
    title: "标签",
    dataIndex: "tagIds",
    customRender: ({ text, record }) => {
      // @ts-ignore
      const mpUserNames = record?.tagNames
      if (!mpUserNames) {
        return ""
      }
      return render.renderTag(mpUserNames.split(","), "green")
    },
    width: 150,
  },
  {
    title: "订阅状态",
    dataIndex: "subscribeStatus",
    customRender: ({ text, record }) => {
      let color = "green"
      if (text == "0") {
        color = "red"
      }
      return render.renderTag(text == "1" ? "已订阅" : "取消订阅", color)
    },
    width: 80,
  },
  {
    title: "订阅时间",
    dataIndex: "subscribeTime",
    width: 160,
  },
  {
    title: "取消订阅时间",
    dataIndex: "unsubscribeTime",
    width: 160,
  },
]

export const searchFormSchema: FormSchema[] = [
  {
    field: "name",
    label: "名称",
    component: "Input",
    colProps: { span: 6 },
  },
  {
    field: "subscribeStatus",
    label: "订阅状态",
    component: "Select",
    componentProps: {
      options: [
        { label: "已订阅", value: "1" },
        { label: "取消订阅", value: "0" },
      ],
    },
    colProps: { span: 8 },
  },
]

export const formSchema: FormSchema[] = [
  {
    field: "id",
    label: "",
    component: "Input",
    show: false,
  },
  {
    field: "nickname",
    label: "昵称",
    required: false,
    component: "Input",
  },

  {
    field: "tagIds",
    label: "标签",
    component: "Select",
  },

  {
    label: "备注",
    field: "remark",
    component: "InputTextArea",
    componentProps: {
      placeholder: "请输入备注",
      rows: 5,
    },
  },
]
